package cn.wolfcode.shop.cloud.msg;

import cn.wolfcode.shop.cloud.CodeMsg;
import lombok.Getter;
import lombok.Setter;

import java.text.MessageFormat;

@Setter
@Getter
public class MemberCodeMsg extends CodeMsg {

    public static final MemberCodeMsg USER_AND_PASS_NOT_NULL = new MemberCodeMsg(50101, "账号密码不能为空");
    public static final MemberCodeMsg USER_NOT_EXISTS = new MemberCodeMsg(50102, "用户不存在");
    public static final MemberCodeMsg PASSWORD_ERROR = new MemberCodeMsg(50103, "密码错误");
    public static final MemberCodeMsg PARAM_ERROR = new MemberCodeMsg(50104, "参数错误:{0}");
    public MemberCodeMsg(int code, String msg) {
        super(code, msg);
    }

    public MemberCodeMsg() {
    }

    public MemberCodeMsg filterArg(String ...arg) {
        MemberCodeMsg memberCodeMsg = new MemberCodeMsg();
        memberCodeMsg.setCode(this.getCode());
        memberCodeMsg.setMsg(MessageFormat.format(this.getMsg(),arg));
        return memberCodeMsg;
    }
}
